
/** 获取天气信息 **/
export async function getWeatherApi (code) {
	return new Promise((resolve, reject) => {
	  uni.request({
		url: `https://restapi.amap.com/v3/weather/weatherInfo?city=${code}&key=92ae1b97b9cb0645cc637ff9378deb14`,
	    method: 'GET',
		header: {'Content-Type': 'application/json'},
	    success: res => {
			if(res.statusCode === 200) {
				resolve({ok: true, msg: '请求成功', data: res.data})
			} else {
				reject({data: null, msg: '系统异常', ok: false})
			}
		},
	    fail: err => reject(err)
	  })
	});
}

/** IP定位 **/
export async function getIpAddrApi () {
	return new Promise((resolve, reject) => {
	  uni.request({
		url: `https://restapi.amap.com/v3/ip?output=json&key=92ae1b97b9cb0645cc637ff9378deb14`,
	    method: 'GET',
		header: {'Content-Type': 'application/json'},
	    success: res => {
			if(res.statusCode === 200) {
				resolve({ok: true, msg: '请求成功', data: res.data})
			} else {
				reject({data: null, msg: '系统异常', ok: false})
			}
		},
	    fail: err => reject(err)
	  })
	});
}